blob: 2b2cc9bb9fb30bcc9f2a748d9ee9b18d61a1db17 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
import type { Metadata } from "next";
import { notFound } from "next/navigation";
import Bookmarks from "@/components/dashboard/bookmarks/Bookmarks";
import ListHeader from "@/components/dashboard/lists/ListHeader";
import { api } from "@/server/api/client";
import { TRPCError } from "@trpc/server";
import { BookmarkListContextProvider } from "@karakeep/shared-react/hooks/bookmark-list-context";
export async function generateMetadata(props: {
params: Promise<{ listId: string }>;
}): Promise<Metadata> {
const params = await props.params;
try {
const list = await api.lists.get({ listId: params.listId });
return {
title: `${list.name} | Karakeep`,
};
} catch (e) {
if (e instanceof TRPCError && e.code === "NOT_FOUND") {
notFound();
}
throw e;
}
}
export default async function ListPage(props: {
params: Promise<{ listId: string }>;
searchParams?: Promise<{
includeArchived?: string;
}>;
}) {
const searchParams = await props.searchParams;
const params = await props.params;
const userSettings = await api.users.settings();
let list;
try {
list = await api.lists.get({ listId: params.listId });
} catch (e) {
if (e instanceof TRPCError) {
if (e.code == "NOT_FOUND") {
notFound();
}
}
throw e;
}
const includeArchived =
searchParams?.includeArchived !== undefined
? searchParams.includeArchived === "true"
: userSettings.archiveDisplayBehaviour === "show";
// Only show editor card if user is owner or editor (not viewer)
const canEdit = list.userRole === "owner" || list.userRole === "editor";
return (
<BookmarkListContextProvider list={list}>
<Bookmarks
query={{
listId: list.id,
archived: !includeArchived ? false : undefined,
}}
showDivider={true}
showEditorCard={list.type === "manual" && canEdit}
header={<ListHeader initialData={list} />}
/>
</BookmarkListContextProvider>
);
}
|